<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/include/inc.jsp"%>
<!DOCTYPE html >
<html>
<head>
	<%@ include file="/WEB-INF/view/jQgrid.jsp"%>
	<script type="text/javascript" src="<%=contextPath %>/static/kindeditor/kindeditor-all-min.js"></script>
    <script charset="utf-8" src="<%=contextPath %>/static/kindeditor/lang/zh-CN.js"></script>
</head>
<body style="background-color: white;" class="gray-bg">
	<div class="ibox-content">
		<form class="form-horizontal m-t" id="signupForm" method="post" enctype="multipart/form-data">
		   <input type="hidden" class="form-control" name="id"  value="${evection.id}"/>
			<div class="form-group">
				<label class="col-sm-3 control-label">出差人名称：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="user1Name" onclick="openTree('user',1);" value="${evection.personName}" readonly="readonly" placeholder="请选择出差人"/>
					<input type="hidden" class="form-control" id="user1Id" name="person" value="${evection.person}"/>
					<p class="help-block" style="color: red;">*必填项，请选择一个系统用户</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">出差地点：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="destination" name="destination"  value="${evection.destination}"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">外出时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control datetime" id="outOfTime" name="outOfTime"  value="${meeting.outOfTime}" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">返岗时间：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control datetime" id="returnTime" name="returnTime"  value="${meeting.returnTime}" readonly="readonly"/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">出差时长：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="difftime" name="difftime"  value="${evection.difftime}"/>
				</div>
			</div>
			<%-- <div class="form-group">
				<label class="col-sm-3 control-label">交通工具：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="vehicleId" name="vehicleId"  value="${evection.vehicleId}"/>
				</div>
			</div> --%>
			<div class="form-group">
				<label class="col-sm-3 control-label">交通工具：</label>
				<div class="col-sm-8">
					<select class="form-control" id="vehicleId" name="vehicleId">
						<c:forEach items="${fns:getDictList('oa_evection_vehicle')}" var="temp1">
							<option value="${temp1.value }" <c:if test="${evection.vehicleId eq temp1.value }">selected</c:if>>${temp1.valueName }</option>
						</c:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-2 control-label">费用预算详情：</label>
				<div class="col-sm-10" >
				  <textarea rows="3" cols="3" class="form-control" style="width: 100%" id="budget" name="budget">${evection.budget}</textarea>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">公司是否预订酒店：</label>
				<div class="col-sm-8">
					<input type="radio" id="reservation2" name="reservation" value="2" <c:if test="${evection.reservation==2}">checked="checked"</c:if>/>否
					<input type="radio" id="reservation1" name="reservation" value="1" <c:if test="${evection.reservation==1}">checked="checked"</c:if>/>是
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<input type="text" class="form-control" id="remark" name="remark"  value="${evection.remark}"/>
				</div>
			</div>
			<div class="form-group" style="text-align: center;">
				<div class="col-sm-8 col-sm-offset-3">
					<button class="btn btn-primary" type="button" id="sub">提交</button>
				</div>
			</div>
		</form>
	</div>


	<script>
	KindEditor.ready(function(K){
		K.create('textarea[name="responsibility${num.count}"]', {
		themeType: 'simple',
		resizeType: 1,
		allowFileManager: true,
		items : [
			'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'emoticons', 'image', 'link'],
		afterBlur: function(){this.sync();}
		});
	});
    $(function () {
    	//日期插件
    	$('#outOfTime').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
	        autoclose: true,
	        todayBtn: true,
	        startView: 'day',
	        minView:'0',
	        maxView:'decade',
	        minuteStep:1,
	        language:  'zh-CN',
	        initialDate : new Date()
	    });
        $('#outOfTime').datetimepicker('setDate',(new Date()));//赋值，当前日期
        $('#returnTime').datetimepicker({
            format: 'yyyy-mm-dd hh:ii:ss',
	        autoclose: true,
	        todayBtn: true,
	        startView: 'day',
	        minView:'0',
	        maxView:'decade',
	        minuteStep:1,
	        language:  'zh-CN',
	        startDate: new Date()
	    });
        $('#returnTime').datetimepicker('setDate',(new Date()));//赋值，当前日期
        $("#reservation1").click(function(){
        	swal({
        		  title: "待开发!",
        		  text: "",
        		  timer: 2000,
        		  showCancelButton: true,
        		  showConfirmButton: false
        	});
        	//要用prop->atrr 。对于HTML元素本身就带有的固有属性，在处理时，使用prop方法。对于HTML元素我们自己自定义的DOM属性，在处理时，使用attr方法
        	//如果使用prop()函数操作表单元素的checked、selected、disabled等属性，如果该元素被选中(或禁用)，则返回true，否则(意即HTML中没有该属性)返回false。
        	//siblings() 方法返回被选元素的所有同级元素。同级元素是共享相同父元素的元素。
        	$('#reservation2').prop("checked","checked").siblings().removeAttr("checked");
     	});
	    $("#sub").click(function () {
        	//批量验证表单非空
			//调用方式
        	var arr=new Array(
        	  new Array('person','出差人未填写!'),
        	  new Array('destination','出差地点未填写!'),
        	  new Array('outOfTime','外出时间未填写!'),
        	  new Array('returnTime','返岗时间未填写!'),
        	  new Array('difftime','出差时长未填写!'),
        	  new Array('vehicleId','交通工具未填写!'),
        	  new Array('budget','费用预算详情未填写!'),
        	  new Array('reservation','公司是否预订酒店未填写!')
        	);
        	  for(var i=0;i<arr.length;i++){
	        	  if($("#"+arr[i][0]).val()==''){
	        		  $("#"+arr[i][0]).tips({
	  					side:3,
	  		            msg:arr[i][1],
	  		            bg:'#AE81FF',
	  		            time:1
	  		        });
	        		  $("#"+arr[i][0]).focus();
	  				return;
	  			}
        	  }
            $("#signupForm").ajaxSubmit({
                url: '<%=contextPath%>/evection/update',
                type: 'post',
                dataType: "json",
                beforeSend: function () {
			        // 禁用按钮防止重复提交
					$("#sub").attr("disabled","disabled");
					swal("信息已经提交，请等待后台处理~！");
			    },
				success : function(data) {
					if (data.code == 200) {
						swal({
							title : data.message,
							type : "success",
							showCancelButton : false,
							confirmButtonText : "确定",
							animation : "slide-from-bottom",
							text: "2秒后自动关闭。", 
	      	    			timer: 2000, 
							closeOnConfirm : true
						}, function() {
							top.Dialog.close();
						});
					} else {
						swal("错误", data.message, "error");
					}  
				},    
				complete: function () {
			        $("#sub").removeAttr("disabled");
			    },
			    error: function (data) {
			    	swal("错误", data.message, "error");
			    }
            });
        });
    }); 
    
    //分配资源
	function openTree(obj,num){
	     var ids = $("#"+obj+num+"Id").val();
	   	 var diag = new top.Dialog();
	   	 var type = "redio";
		 diag.Drag=true;
		 diag.Title ="请选择";
		 diag.URL = '<%=contextPath %>/'+obj+'/openZtree?ids='+ids+'&types='+type;
		 diag.Width = 250;
		 diag.Height = 400;
		 diag.CancelEvent = function(){ //关闭事件
			 var tempid = diag.innerFrame.contentWindow.document.getElementById('tempids').value;
			 var tempname = diag.innerFrame.contentWindow.document.getElementById('tempnames').value;
			if(tempid.length!==0){
				if(typeof(num)=="undefined"){ 
					$("#"+obj+"Id").val(tempid);
					$("#"+obj+"Name").val(tempname);
				}else{
					$("#"+obj+num+"Id").val(tempid);
					$("#"+obj+num+"Name").val(tempname);
				}
			}
			diag.close();
		 };
		 diag.show();
	}
</script>
</body>
</html>